// 定义实现类的接口
interface Implementor {
    void operation();
}

// 定义抽象类
abstract class Abstraction {
    protected Implementor implementor;

    public Abstraction(Implementor implementor) {
        this.implementor = implementor;
    }

    abstract void request();
}

// 扩展抽象类
class RefinedAbstraction extends Abstraction {
    public RefinedAbstraction(Implementor implementor) {
        super(implementor);
    }

    @Override
    void request() {
        // 实现扩展功能
        System.out.println("Refined request");
        implementor.operation();
    }
}

// 具体实现类A
class ConcreteImplementorA implements Implementor {
    @Override
    public void operation() {
        System.out.println("ConcreteImplementorA operation");
    }
}

// 具体实现类B
class ConcreteImplementorB implements Implementor {
    @Override
    public void operation() {
        System.out.println("ConcreteImplementorB operation");
    }
}

// 客户端代码
public class BridgePatternDemo {
    public static void main(String[] args) {
        // 使用具体实现类A
        Abstraction abstractionA = new RefinedAbstraction(new ConcreteImplementorA());
        abstractionA.request();

        // 使用具体实现类B
        Abstraction abstractionB = new RefinedAbstraction(new ConcreteImplementorB());
        abstractionB.request();
    }
}